﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using YhmOA.Common;
using YhmOA.Model;
using YhmOA.IDAL;

namespace YhmOA.ManagerOA.Menu
{
    public partial class TopMenuManager : BasePage
    {
        public int TopID
        {
            get
            {
                return Convert.ToInt32(Request.QueryString["topID"] ?? "0");
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ManagerOA_Menu_TopMenu info = DataProvider.GetGEFDal<ITDal<ManagerOA_Menu_TopMenu>>().GetModelByID(this.TopID);
                this.txt_ChildMenuID.Text = info.ChildID;
                this.txt_ChildMenuName.Text = info.ChildName;
                BindData();
            }
        }

        [AjaxMethod]
        public void BindDataGridView()
        {
            ManagerOA_Menu_TopMenu info = DataProvider.GetGEFDal<ITDal<ManagerOA_Menu_TopMenu>>().GetModelByID(this.TopID);
            info.ChildID = this.txt_ChildMenuID.Text.Trim();
            info.ChildName = this.txt_ChildMenuName.Text.Trim();
            DataProvider.GetGEFDal<ITDal<ManagerOA_Menu_TopMenu>>().Update(info, this.TopID);
            BindData();
        }

        public void BindData()
        {
            string ID = this.txt_ChildMenuID.Text;
            int count = 0;
            string whereStr = "ID in (-1," + ID.Trim() + ")";
            List<ManagerOA_Menu_LeftMenu> list = DataProvider.GetGEFDal<ITDal<ManagerOA_Menu_LeftMenu>>().SearchTable(whereStr, "*", "", 0, 0, "ID", "DESC", out count);
            this.gvShow.DataSource = list;
            this.gvShow.AutoGenerateColumns = false;
            this.gvShow.DataBind();
        }

        #region GridView的行绑定事件
        protected void gvShow_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {

            }
        }
        #endregion

        #region GridView的行内事件
        protected void gvShow_RowCommand(object sender, GridViewCommandEventArgs e)
        {

        }
        #endregion
    }
}